home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlxinstl.zip / PRINTAT.ASM < prev    next >
Assembly Source File  |  1990-09-13  |  2KB  |  112 lines

  1. CALC_ADDR    MACRO  mrow,mcol
  2.         push    si
  3.         push    ax
  4.         mov    al,mrow
  5.         mov    row,al
  6.         mov    ax,mcol
  7.         mov    col,ax
  8.         mov    ah,0
  9.         mov    al,row
  10.         shl    ax,1    ;;*2
  11.         shl    ax,1    ;;*4
  12.         shl    ax,1    ;;*8
  13.         shl    ax,1    ;;*16
  14.         mov    di,ax    ;;save partial result
  15.         shl    ax,1    ;;*32
  16.         shl    ax,1    ;;*64
  17.         add    di,ax    ;;di = line * 80
  18.         mov    ax,col    ;;add in column
  19.         add    di,ax
  20.         shl    di,1    ;;adjust for attribute bytes
  21.         pop    ax
  22.         pop    si
  23.         ENDM
  24.  
  25. CURSOR    MACRO
  26.     push    si
  27.     push    ax
  28.     XOR    BX,BX
  29.     mov    bx,col
  30.     mov    dh,row          ;;row
  31.     mov    dl,bl          ;;col
  32.     MOV    AH,2        ;;SET CURSOR
  33.     INT    10H
  34.     XOR    BX,BX
  35.     MOV    AH,8           ;;RETURN CHARACTER AND ATTRIBUTE AT CURSOR
  36.     INT    10H
  37.     MOV    BX,AX
  38.     pop    ax
  39.     pop    si
  40.     ENDM
  41.  
  42.  
  43. EQUIP_CHK    MACRO
  44.     local    seg_ok
  45.         int    11H
  46.         and    al,00110000B    ;;is it B/W?
  47.         cmp    al,00110000B
  48.         mov    ax,0b000H    ;;assume B/W
  49.         mov    stat_port,03baH
  50.         je    seg_ok
  51.         mov    ax,0b800H    ;;no, set color
  52.         mov    stat_port,03daH
  53. seg_ok:
  54.         mov    video_address,ax
  55.         ENDM
  56.  
  57. .MODEL HUGE, C
  58. .CODE
  59.  
  60. PRINTAT    PROC     ARG1, ARG2
  61. PUBLIC PRINTAT
  62.  
  63. jmp    start
  64.  
  65. screen_attr      db        0
  66. inv_screen_attr   db        70H
  67. stat_port      dw        0
  68. video_address      dw        0
  69. colcnt          dw        0
  70. linecnt       dw        0
  71. COL          dw        ?        ;Contains the current column
  72. ROW          db        ?        ;Contains the current row
  73. startl          db        0        ;offset to parameter variable
  74. startc          dw        0        ;offset to parameter variable
  75. stradd          dw        0        ;offset to parameter variable
  76.  
  77. start:
  78.     mov    ax,arg1
  79.     mov    startl,al
  80.     mov    ax,arg2
  81.     mov    startc,ax
  82.  
  83.     push    es
  84.  
  85.     EQUIP_CHK          ;macro determines if color or mono
  86.     MOV    ES,AX          ;screen is connected
  87.     CMP    AX,0B000H
  88.     JNE    COLOR
  89.  
  90. SCREEN    SEGMENT  AT   0B000H      ;Monochrome screen
  91. SCREEN    ENDS
  92.     JMP    SET_SCREEN
  93.  
  94. COLOR:
  95. SCREEN    SEGMENT  AT   0B800H      ;Color screen
  96. SCREEN    ENDS
  97.  
  98. SET_SCREEN:
  99.     ASSUME    ES:SCREEN
  100.  
  101.     XOR    BX,BX
  102.     MOV    AH,8           ;;RETURN CHARACTER AND ATTRIBUTE AT CURSOR
  103.     INT    10H
  104.     mov    screen_attr,ah
  105.     calc_addr startl,startc     ;;location of top left
  106.     cursor
  107.     pop    es
  108.     RET
  109. PRINTAT  ENDP
  110.     END
  111.  
  112.